import {defineStore} from 'pinia'
import {reqGetSearchInfo} from '@/api'
import {ListParamsType} from '@/api/types'
import {SearchType} from './types'
//search模块的仓库
export const useSearchStore = defineStore('search', {
    state: () => ({
        searchList: <SearchType>{}
    }),
    getters: {
        goodsList(state) {
            return state.searchList.goodsList || []
        },
        trademarkList(state) {
            return state.searchList.trademarkList || []
        },
        attrsList(state) {
            return state.searchList.attrsList || []
        }
    },
    actions: {
        //获取search模块数据
        async getSearchList(params: ListParamsType = {}) {
            let result = await reqGetSearchInfo(params)
            if (result.code == 200) {
                this.searchList = result.data
            }
        }
    }
})
